﻿using Military_Madness.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Military_Madness
{
    public class Map
    {
        private static readonly Bitmap[] Chips = new Bitmap[] { Resources.chip_0, Resources.chip_1, Resources.chip_2, Resources.chip_3, Resources.chip_4 };

        private const int ChipWidth = 48;
        private const int ChipHeight = 48;

        private const int TransverseCount = 8;
        private const int VerticalCount = 8;

        private const int SingleBitmapChipCount = 64;

        public static void DrawChip(Graphics Graphics, int Index, int X, int Y)
        {
            int ChipIndex = 0;

            while (Index >= SingleBitmapChipCount)
            {
                ++ChipIndex;
                Index -= SingleBitmapChipCount;
            }

            int ChipX = (Index % TransverseCount) * ChipWidth;
            int ChipY = (Index / VerticalCount) * ChipHeight;

            Graphics.DrawImage(Chips[ChipIndex], new Rectangle(X, Y, ChipWidth, ChipHeight), new Rectangle(ChipX, ChipY, ChipWidth, ChipHeight), GraphicsUnit.Pixel);
        }
    }
}
